﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.ShimManager
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Collections.Generic;
using System.Linq;

#nullable disable
namespace UnityEngine
{
  internal class ShimManager
  {
    internal static Action ActiveShimChanged;
    private static List<ScreenShimBase> s_ActiveScreenShim = new List<ScreenShimBase>((IEnumerable<ScreenShimBase>) new ScreenShimBase[1]
    {
      new ScreenShimBase()
    });
    private static List<SystemInfoShimBase> s_ActiveSystemInfoShim = new List<SystemInfoShimBase>((IEnumerable<SystemInfoShimBase>) new SystemInfoShimBase[1]
    {
      new SystemInfoShimBase()
    });
    private static List<ApplicationShimBase> s_ActiveApplicationShim = new List<ApplicationShimBase>((IEnumerable<ApplicationShimBase>) new ApplicationShimBase[1]
    {
      new ApplicationShimBase()
    });

    internal static ScreenShimBase screenShim
    {
      get => ShimManager.s_ActiveScreenShim.Last<ScreenShimBase>();
    }

    internal static SystemInfoShimBase systemInfoShim
    {
      get => ShimManager.s_ActiveSystemInfoShim.Last<SystemInfoShimBase>();
    }

    internal static ApplicationShimBase applicationShim
    {
      get => ShimManager.s_ActiveApplicationShim.Last<ApplicationShimBase>();
    }

    internal static void UseShim(ScreenShimBase shim)
    {
      if (ShimManager.s_ActiveScreenShim.Last<ScreenShimBase>() == shim)
        return;
      ShimManager.RemoveShim(shim);
      ShimManager.s_ActiveScreenShim.Add(shim);
      Action activeShimChanged = ShimManager.ActiveShimChanged;
      if (activeShimChanged == null)
        return;
      activeShimChanged();
    }

    internal static void UseShim(SystemInfoShimBase shim)
    {
      if (ShimManager.s_ActiveSystemInfoShim.Last<SystemInfoShimBase>() == shim)
        return;
      ShimManager.RemoveShim(shim);
      ShimManager.s_ActiveSystemInfoShim.Add(shim);
      Action activeShimChanged = ShimManager.ActiveShimChanged;
      if (activeShimChanged == null)
        return;
      activeShimChanged();
    }

    internal static void UseShim(ApplicationShimBase shim)
    {
      if (ShimManager.s_ActiveApplicationShim.Last<ApplicationShimBase>() == shim)
        return;
      ShimManager.RemoveShim(shim);
      ShimManager.s_ActiveApplicationShim.Add(shim);
      Action activeShimChanged = ShimManager.ActiveShimChanged;
      if (activeShimChanged == null)
        return;
      activeShimChanged();
    }

    internal static void RemoveShim(ScreenShimBase shim)
    {
      if (!ShimManager.s_ActiveScreenShim.Contains(shim))
        return;
      ShimManager.s_ActiveScreenShim.Remove(shim);
      Action activeShimChanged = ShimManager.ActiveShimChanged;
      if (activeShimChanged != null)
        activeShimChanged();
    }

    internal static void RemoveShim(SystemInfoShimBase shim)
    {
      if (!ShimManager.s_ActiveSystemInfoShim.Contains(shim))
        return;
      ShimManager.s_ActiveSystemInfoShim.Remove(shim);
      Action activeShimChanged = ShimManager.ActiveShimChanged;
      if (activeShimChanged != null)
        activeShimChanged();
    }

    internal static void RemoveShim(ApplicationShimBase shim)
    {
      if (!ShimManager.s_ActiveApplicationShim.Contains(shim))
        return;
      ShimManager.s_ActiveApplicationShim.Remove(shim);
      Action activeShimChanged = ShimManager.ActiveShimChanged;
      if (activeShimChanged != null)
        activeShimChanged();
    }

    internal static bool IsShimActive(ScreenShimBase shim)
    {
      return ShimManager.s_ActiveScreenShim.Last<ScreenShimBase>() == shim;
    }

    internal static bool IsShimActive(SystemInfoShimBase shim)
    {
      return ShimManager.s_ActiveSystemInfoShim.Last<SystemInfoShimBase>() == shim;
    }

    internal static bool IsShimActive(ApplicationShimBase shim)
    {
      return ShimManager.s_ActiveApplicationShim.Last<ApplicationShimBase>() == shim;
    }

    internal static bool IsScreenShimActive() => ShimManager.s_ActiveScreenShim.Count > 1;

    internal static bool IsSystemInfoShimActive() => ShimManager.s_ActiveSystemInfoShim.Count > 1;

    internal static bool IsApplicationShimActive() => ShimManager.s_ActiveApplicationShim.Count > 1;
  }
}
